package cn.joeg.app.web.items.demo;

import cn.joeg.app.GCore;
import cn.joeg.app.web.core.def.AbstractWidgetAdapter;
import cn.joeg.app.web.core.vo.WidgetDataResp;
import com.ecfront.dew.common.Resp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


/**
 *
 */
@Component("demo")
public class WidgetAdapter extends AbstractWidgetAdapter {

    private static final String WIDGET_CODE = "demo";

    private static final Logger logger = LoggerFactory.getLogger(WidgetAdapter.class);

    @Override
    public String getCode() {
        return WIDGET_CODE;
    }

    public Resp<WidgetDataResp> getCahceDataByKey(WidgetReqVO req) {
        String key = req.getKey();
        WidgetRespVO.CacheData cacheData = new WidgetRespVO.CacheData();
        cacheData.setData(GCore.cluster.cache.get(key));
        return Resp.success(WidgetDataResp.build(cacheData));

    }


}
